clear

*run ${fmartorell_home}/top_program

set more off

*log using ${fmartorell_home}programs/uniqenroll, replace
log using ${d1}do/uniqenroll.log, replace

forvalues y=1990/2000 {
 use ${nh_data}/TEA_PEIMS/Enroll/Enroll`y' if grade>=11, clear
 keep if real(ssn)<.
 rename ssn altpid
 cap rename birth bthday
 keep altpid sex ethnic bthday lep gifted atrisk econ_dis title1
 gen obs=_n
 sort altpid obs
 by altpid: keep if _n==1
 gen y=`y'
 *save ${fmartorell_home}/tmp/tmpenr`y', replace
 save ${d1}tmp/tmpenr`y', replace
}



*use ${fmartorell_home}/tmp/tmpenr1990, clear
use ${d1}tmp/tmpenr1990, clear
forvalues y=1991/2000 {
 *qui append using ${fmartorell_home}/tmp/tmpenr`y'
 qui append using ${d1}tmp/tmpenr`y'
}

sort altpid bthday y
by altpid: gen samebd=bthday[1]==bthday[_N] if _N>1
egen tag=tag(altpid) if samebd!=.

tab samebd if tag==1

keep if samebd==1

by altpid: keep if _n==1

compress

*save ${fmartorell_home}/data/uniqenroll, replace
save ${d1}data/uniqenroll, replace

log close
